#!/bin/sh
HOLD1=/tmp/hold1.$$
PROCESS=$1

usage()
{
	#usage
	echo "Usage : 'basename $0' process_name"
	exit 1
}

if [ $# -ne 1 ] ; then
	usage
fi

case $1 in
*)
	# grep the process, do not include our script in the output from ps
	# extract fields 1 and 6, redirect to a temp file.
	ps x | grep $PROCESS | grep -v $0 | awk '{print $1"\t" $6}'>$HOLD1
	;;
esac

# is the file there ??
if [ ! -s $HOLD1 ]; then
	echo "No Processes found... sorry"
	exit 1
fi

# read in the contents form the temp file and display the fields 
while read LOOP1 LOOP2
do 
	echo $LOOP1 $LOOP2
done <$HOLD1
echo -n "Are these the processes to be killed ? [y..n] > "
read ANS

case $ANS in
Y|y) while read LOOP1 LOOP2
do
	echo $LOOP1
	kill -9 $LOOP1
done <$HOLD1
	rm /tmp/*.$$
	;;
N|n);;
esac
